package its.opt.graphs;

import its.opt.structures.NodeListItem;

public class LabeledTreeNode {

	public LabeledTreeNodeType type;
	public int depth;
	public int numParents;
	public int label;
	public double[] distribution;

	public LabeledTreeNode left;
	public LabeledTreeNode right;
	public LabeledTreeNode[] parent;
	public NodeListItem leavesItem;
	public NodeListItem leafsParentsItem;

	public byte[] parentLabelCoincidenceVector;

	/** Gains of contribution for split on i'th node */
	public double[] gains;
	public double[] rightValue0Array;
	public double[] rightValue1Array;
	public double[] leftValue0Array;
	public double[] leftValue1Array;

	public LabeledTreeNode(LabeledTreeNodeType type) {
		this.type = type;
		this.label = -1;
		this.depth = 0;
		this.distribution = new double[2];
		this.distribution[0] = this.distribution[1] = 0.0d;
	}

	/**
	 * allocates a coincidence vector containing 1's for all ancestors in a
	 * decision graph
	 * 
	 * @param n
	 *          the number of possible values (labels) of ancestors
	 */
	public void allocateInstanceIndexEntries(int n) {
		parentLabelCoincidenceVector = new byte[n];
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Node ");
		builder.append(label);
		builder.append(" type: ");
		builder.append(type);
		if (distribution != null) {
			builder.append(" distribition:[");
			builder.append(distribution[0]);
			builder.append(", ");
			builder.append(distribution[1]);
			builder.append("]");
		}
		return builder.toString();
	}
	
	
}
